package cn.ibizlab.todo.core.pms.service.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.Map;
import java.util.HashSet;
import java.util.HashMap;
import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
import java.math.BigInteger;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.util.ObjectUtils;
import org.springframework.beans.factory.annotation.Value;
import cn.ibizlab.todo.util.errors.BadRequestAlertException;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.context.annotation.Lazy;
import cn.ibizlab.todo.core.pms.domain.Action;
import cn.ibizlab.todo.core.pms.filter.ActionSearchContext;
import cn.ibizlab.todo.core.pms.service.IActionService;

import cn.ibizlab.todo.util.helper.CachedBeanCopier;
import cn.ibizlab.todo.util.helper.DEFieldCacheMap;


import cn.ibizlab.todo.core.pms.client.ActionFeignClient;

/**
 * 实体[系统日志] 服务对象接口实现
 */
@Slf4j
@Service
public class ActionServiceImpl implements IActionService {

    @Autowired
    ActionFeignClient actionFeignClient;


    @Override
    public boolean create(Action et) {
        Action rt = actionFeignClient.create(et);
        if(rt==null)
            return false;
        CachedBeanCopier.copy(rt,et);
        return true;
    }

    public void createBatch(List<Action> list){
        actionFeignClient.createBatch(list) ;
    }

    @Override
    public boolean update(Action et) {
        Action rt = actionFeignClient.update(et.getId(),et);
        if(rt==null)
            return false;
        CachedBeanCopier.copy(rt,et);
        return true;

    }

    public void updateBatch(List<Action> list){
        actionFeignClient.updateBatch(list) ;
    }

    @Override
    public boolean remove(Long id) {
        boolean result=actionFeignClient.remove(id) ;
        return result;
    }

    public void removeBatch(Collection<Long> idList){
        actionFeignClient.removeBatch(idList);
    }

    @Override
    public Action get(Long id) {
		Action et=actionFeignClient.get(id);
        if(et==null){
            et=new Action();
            et.setId(id);
        }
        else{
        }
        return  et;
    }

    @Override
    public Action getDraft(Action et) {
        et=actionFeignClient.getDraft();
        return et;
    }

    @Override
    public boolean checkKey(Action et) {
        return actionFeignClient.checkKey(et);
    }
    @Override
    @Transactional
    public boolean save(Action et) {
        if(et.getId()==null) et.setId((Long)et.getDefaultKey(true));
        if(!actionFeignClient.save(et))
            return false;
        return true;
    }

    @Override
    public void saveBatch(List<Action> list) {
        actionFeignClient.saveBatch(list) ;
    }





    /**
     * 查询集合 数据集
     */
    @Override
    public Page<Action> searchDefault(ActionSearchContext context) {
        Page<Action> actions=actionFeignClient.searchDefault(context);
        return actions;
    }

    /**
     * 查询集合 动态(根据类型过滤)
     */
    @Override
    public Page<Action> searchType(ActionSearchContext context) {
        Page<Action> actions=actionFeignClient.searchType(context);
        return actions;
    }




}



